<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>改卷</title>
   
    <script src="/testSystem/js/jquery-3.2.1.min.js"></script>
</head>
<body>
       <table>
           <thead>
               <h1 align="center">改卷</h1>
           </thead>
           <tbody align="center" id="shijuan">
               
           </tbody>
       </table>
       
       <script type="text/javascript">
           
           //获取试卷 
           $(function(){
        	   var url = window.location;
        	   var ksh = getUrlParam(url,"ksh");
        	   var worksId = getUrlParam(url,"worksid");
        	   $.ajax({
	    	    	url:"/testSystem/selectStupaper",
	    	    	type:"post",
	    	    	dataType:"json",
	    	    	data:"ksh="+ksh+"&worksId="+worksId,
	    	    	success:function(result){
	    	    		console.log(result);
	    	    		$.each(result.extend.list,function(i,item){    		 
	    		    		var tr1 = $("<tr></tr>");
	    		    		var tr1td1 = $('<td></td>');
	    		    		var h31 = $('<h3></h3>');
	    		    		var strong1 = $('<strong></strong>').append('题目：');
	    		    		h31.append(strong1);
	    		    		tr1td1.append(h31);
	    		    		tr1.append(tr1td1);
	    		    		var tr1td2 = $('<td></td>').append(item.questiontitle);
	    		    		tr1.append(tr1td2);
	    		    		
	    		    		var tr2 = $("<tr></tr>");
	    		    		var tr2td1 = $('<td></td>');
	    		    		var h32 = $('<h3></h3>');
	    		    		var strong2 = $('<strong></strong>').append('答案：');
	    		    		h32.append(strong2);
	    		    		tr2td1.append(h32);
	    		    		tr2.append(tr2td1);
	    		    		var tr2td2 = $('<td></td>').append(item.code);
	    		    		tr2.append(tr2td2);
	    		    		
	    		    		var tr4 = $("<tr></tr>");
	    		    		var tr4td1 = $('<td></td>');
	    		    		var h42 = $('<h3></h3>');
	    		    		var strong4 = $('<strong></strong>').append('分数：');
	    		    		var tr4td2 = $('<td></td>');
	    		    		var input1 = $('<input type="text" id="fenshu" />');
	    		            
	    		    	    h42.append(strong4);
	    		    	    tr4td1.append(h42);
	    		    	    tr4.append(tr4td1);
	    		    	    if(item.status){
	    		    	    	tr4td2.append("已改");
	    		    	    }else{
	    		    	    	tr4td2.append(input1);
	    		    	    }
	    		    	    //tr4td2.append(input1);
	    		    	    tr4.append(tr4td2);
	    		    		
	    		    		var tr3 = $("<tr></tr>");
	    		    		var tr3td1 = $('<td></td>');
	    		    		var input = $('<input type="button" id="chengji" value="提交"  />');
	    		    		tr3td1.append(input);
	    		    		tr3.append(tr3td1);
	    		    		//提交点击事件 
	    		    		input.click(function(){
	    		    			alert("提交");
	    		    			var fenshu = $('#fenshu').val();
	    		    			alert(fenshu);
	    		    			$.ajax({
	    		    				url:"/testSystem/changeTheTopic",
	    			    	    	type:"post",
	    			    	    	dataType:"json",
	    			    	    	data:"ksh="+ksh+"&worksId="+worksId+"&questionid="+item.id+"&grade="+fenshu,
	    			    	    	success:function(result){
	    			    	    		console.log(result);
	    			    	    	}
	    		    			});
	    		    		});
	    		    		$('#shijuan').append(tr1).append(tr2).append(tr4).append(tr3);
	    		        });
	    	    	}
	    	    });
           });

           /***
           获取url地址上参数
           */
function getUrlParam(url,name){
        var pattern = new RegExp("[?&]" + name +"\=([^&]+)","g");
        var matcher = pattern.exec(url);
        var items = null;
        if(matcher != null){
            try{
                items = decodeURIComponent(decodeURIComponent(matcher[1]));   
            }catch(e){
                try{
                    items = decodeURIComponent(matcher[1]);
                }catch(e){
                    items = matcher[1];
                }
            }
        }
        return items;
    }
       </script>
</body>
</html>